package february.test_2_28;

public class Gloves {

    public int findMinimum(int n, int[] left, int[] right) {
        // write code here
        int lz = 0;
        int rz = 0;
        int lh = 0;
        int rh = 0;
        int[] arr = findZero(left,right);
        for(int i = 0; i < n; i++) {
            if(arr[i] == 1) {
                lz += left[i];
                rz += right[i];
            } else {
                lh += left[i];
                rh += right[i];
            }
        }
        int one = lz + lh + rz;
        int two = rz + rh + lz;
        return Math.min(one,two) + 1;
    }
    public int[] findZero(int[] left,int[] right) {
        int[] arr = new int[left.length];
        for(int i = 0; i < left.length; i++) {
            if(left[i]*right[i] == 0) {
                arr[i] = 1;
            }
        }
        return arr;
    }
}
